//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================

#ifndef __ELASTOS_SYSCALL_H__
#define __ELASTOS_SYSCALL_H__

#include <sysnum.h>
#include <crust.h>

typedef struct _RegInArg
{
    EMuid * pCLSID;
    EIID   * pIID;
} RegInArg;

typedef struct _ResolveOutArg
{
    CIClassEntry ** ppClsInfo;
    PContext *ppContext;
} ResolveOutArg;

typedef struct _InvokeInArg
{
    oid_t oid;
    bool_t async;
} InvokeInArg;

#define DECL_SYSTEMCALL     EXTERN_C ECode CDECL

#define MAX_SHARED_MEM_OF_CLSINFO  0x40000

void InitSharedClsInfo();

ECode LookupSharedClassEntry(
        REMuid rclsid,
        CIClassEntry **ppClassEntry);

ECode UnregisterSharedClassInfo(
        /* [in] */  CIClassInfo *pClassInfo);

ECode RegisterSharedClassInfo(
        /* [in] */  CIClassInfo *pClassInfo);

DECL_ASMLINKAGE virtaddr_t g_fnSystemCalls[];

DECL_SYSTEMCALL SysRegister(
        IStub *pIStub, EMuid * pCLSID, EIID * pIID,
        oid_t *pOid, CIClassEntry ** ppClsInfo);

DECL_SYSTEMCALL SysUnregister(oid_t oid);

DECL_SYSTEMCALL SysRegisterCommon(
        const wchar_t * pszName,
        IStub * pIStub, RegInArg * pRegInArg, oid_t * pRet,
        CIClassEntry ** ppClsInfo);

DECL_SYSTEMCALL SysResolveCommon(
        const wchar_t * pszName, oid_t * pRet,
        EMuid * pClsid, UInt32 * puIndex, ResolveOutArg *pResolveOutArg);

DECL_SYSTEMCALL SysUnregisterCommon(const wchar_t * pwszName);

DECL_SYSTEMCALL SysInvoke(
        InvokeInArg * pInvokeInArg, void *pvInBuf,
        size_t uInBufSize, void *pvOutBuf, size_t uOutBufSize);

DECL_SYSTEMCALL SysReply(ECode ec,
        void *pvOutBuf, size_t uOutBufSize);

DECL_SYSTEMCALL SysPrint(const wchar_t *wszMessage);

DECL_SYSTEMCALL SysGetMemtraceArgs(wchar_t *pwchArgId, Int32 *pIndex,
                                            Address *pWatchAddr);

DECL_SYSTEMCALL SysGetVirtualCode(struct KBDStatus *pVirtulCode);

DECL_SYSTEMCALL SysBreak(uint_t uAddr);

DECL_SYSTEMCALL _SysRegister(
        IStub *pIStub, UInt32 uIndex, oid_t *pOid,
        CIClassEntry ** ppClsInfo, CProcess * pCProcess);

DECL_SYSTEMCALL _SysRegisterCommon(
        const wchar_t * pszName, IStub * pIStub,
        UInt32 uIndex, oid_t * pRet,
        CIClassEntry ** ppClsInfo, CProcess * pCProcess);

DECL_SYSTEMCALL SysExitThread(ECode exitCode);

DECL_SYSTEMCALL SysAttachServer(oid_t oid, PContext pContext);

DECL_SYSTEMCALL SysDetachServer(oid_t oid, PContext pContext);

DECL_SYSTEMCALL SysCreateEvent(PVoid *pEventHandle);

DECL_SYSTEMCALL SysDestroyEvent(PVoid eventHandle);

DECL_SYSTEMCALL SysNotifyEvent(PVoid eventHandle);

DECL_SYSTEMCALL SysWaitEvent(PVoid eventHandle);

DECL_SYSTEMCALL SysSetBreakPoint(
        UInt32 uNo, BreakPointType type, void *pvAddress, UInt32 uLength);

DECL_SYSTEMCALL SysSleep(int ms, WaitResult *pResult);

DECL_SYSTEMCALL SysSendToKernel(UInt32 *buf, UInt32 type);

#endif // __ELASTOS_SYSCALL_H__
